//
//  SearchCell.m
//  CarLifes
//
//  Created by yu on 2017/9/4.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "SearchCell.h"
#import "Utility.h"

@implementation SearchCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = kTextLightGrayColor;
    [self.contentView addSubview:lineView];
    
    lineView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .rightSpaceToView(self.contentView, 10)
    .bottomEqualToView(self.contentView)
    .heightIs(0.5);
}

- (void)updateAttributedTextWithModel:(EquipmentModel *)model keyword:(NSString *)keyword {
    
    // 车主名
    if (model.ownerName.length != 0)
    {
        NSAttributedString *attrString = [Utility attributeStringWithContent:model.ownerName keyword:keyword];
        self.ownerNameLabel.attributedText = attrString;
    } else {
        self.ownerNameLabel.text = @"";
    }
    
    // 车牌号
    if (model.plateNum.length != 0)
    {
        NSAttributedString *attrString = [Utility attributeStringWithContent:model.plateNum keyword:keyword];
        self.plateNumLabel.attributedText = attrString;
    } else {
        self.plateNumLabel.text = @"";
    }
    
    // 设备号
    if (model.eqNo.length != 0)
    {
        NSAttributedString *attrString = [Utility attributeStringWithContent:model.eqNo keyword:keyword];
        self.eqNoLabel.attributedText = attrString;
    } else {
        self.eqNoLabel.text = @"";
    }

    // 合同号
    if (model.contractNo.length != 0)
    {
        NSAttributedString *attrString = [Utility attributeStringWithContent:model.contractNo keyword:keyword];
        self.contractNoLabel.attributedText = attrString;
    } else {
        self.contractNoLabel.text = @"";
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
